package com.yc.zk.common;

import java.util.List;

public class CommonHelper {
    /**
     * 查询zookeeper主机列表中的leader
     *
     * @param stringList
     * @return
     */
    public static String findMaster(List<String> stringList) {
        Integer min = Integer.MAX_VALUE;
        Integer index = 0;
        for (int i = 0; i < stringList.size(); i++) {
            Integer num = Integer.parseInt(stringList.get(i).substring(4));
            if (num <= min) {
                min = num;
                index = i;
            }
        }
        return stringList.get(index);
    }
}
